<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="zh-cn">
    <head>
        <!-- Bootstrap -->
        <include file="Include/css" />
        <title></title>
        <link href="__STATICS__/css/admin/index.css" rel="stylesheet">
        <link href="__STATICS__/css/sweet-alert.css" rel="stylesheet">
        <script type="text/javascript" src="__STATICS__/js/sweet-alert.min.js"></script>
    </head>

    <body>
        <include file="Include/nav_top" />
        <div class="container clearfix" id="left_menu_wraper" >
            <include  file="Include/menu_left" />
            <div id="right-content">
                <div id="right-content-inner">
                    <ul class="breadcrumb">
                        <span>您的位置：</span>
                        <li><a href="{:U('Houtai/Index/index')}">首页</a> </li>
                        <li class="">版本管理</li>
                        <li class="active">版本列表</li>
                    </ul>
                    <p>
                        <button id="add_look" class="btn btn-orange" type="button" >
                            添加版本
                        </button>
                    </p>
                    <div role="tabpanel">
                        <div class="row clearfix margin10 form-horizontal">
                            <form  name="query" >
                                <span class="pull-left ml30 form_bar">查询：</span>
                                <div class="col-md-2">
                                    <input type="text" name="sVersion" value="{$Think.request.sVersion}" placeholder=" 版本号" class="pull-left ml10 form-control" />
                                </div>
                                <div class="col-md-2">
                                    <select  name="sDevice" class="pull-left ml10 form-control" >
                                            <option value="all" <eq name="Think.request.sDevice" value="all" > selected </eq> >-选择设备-</option>
                                            <option value="ios" <eq name="Think.request.sDevice" value="ios" > selected </eq> >ios</option>
                                            <option value="android" <eq name="Think.request.sDevice" value="android" > selected </eq> >android</option>
                                    </select>
                                </div>
                                <div class="col-md-2">
                                    <select  name="sStatus" class="pull-left ml10 form-control" >
                                            <option value="-1" <eq name="Think.request.sStatus" value="-1" > selected </eq> >-订单状态-</option>
                                            <option value="0" <eq name="Think.request.sStatus" value="0" > selected </eq> >未发布</option>
                                            <option value="1" <eq name="Think.request.sStatus" value="1" > selected </eq> >已发布</option>
                                            <option value="2" <eq name="Think.request.sStatus" value="2" > selected </eq> >已停用</option>
                                    </select>
                                </div>
                                <button type="submit" class="pull-left btn btn-default ml20">搜索</button>
                            </form>
                        </div>
                                <table class="table ">
                                    <thead class="table_head">
                                        <tr class="border">
                                            <th>编号</th>
                                            <th>APPID</th>
                                            <th>APPKey</th>
                                            <th>设备</th>
                                            <th>版本号</th>
                                            <th>URL</th>
                                            <th>状态</th>
                                            <th>添加时间</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <volist name="list" id="vo">
                                            <tr class="qr_tar" >
                                                <td  >
                                                    {$i+$num}
                                                </td>
                                                <td >
                                                {$vo.appID}
                                                </td>
                                                <td >
                                                {$vo.appKey}
                                                </td>
                                                <td >
                                                {$vo.device}
                                                </td>
                                                <td >
                                                {$vo.version}
                                                </td>
                                                <td>{$vo.url}</td>
                                                <td>
                                                    <switch name="vo['status']" >
                                                        <case value="0"><span class="text-blue">未发布</span></case>
                                                        <case value="1"><span class="text-success ">已发布</span></case>
                                                        <case value="2"><span class="text-warning ">已停用</span></case>
                                                    </switch>
                                                </td>
                                                <td>{$vo['addTime'] | date="Y/m/d H:i:s",###} </td>
                                                <td data-id="{$vo.verID}" data-appid="{$vo.appID}" 
                                                    data-appkey="{$vo.appKey}" data-device="{$vo.device}" 
                                                    data-version="{$vo.version}" data-url="{$vo.url}" 
                                                    data-status="{$vo.status}" data-content="{$vo.content}" 
                                                data-time="{$vo['addTime']|date='Y/m/d H:i:s',###}" >
                                                    <a href="javascript:void(0);" class="edit_look" >编辑</a>
                                                    /
                                                    <a href="javascript:void(0);" class="tar_delete" >删除</a>
                                                </td>
                                            </tr>
                                        </volist>
                                    </tbody>
                                </table>

                                <div class="clearfix s_page pull-right">
                                    {$page}
                                </div>
                            </div>

                    </div>

                </div>

            </div>
        
        <!-- 任务基本信息 Modal - 开始 -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel"> </h4>
                    </div>
                    <div class="modal-body">
                        <div role="tabpanel" class="tab-pane active" id="home">

                            <div class="row clearfix add_hide">
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                        APPID：
                                    </div>
                                    <div class="col-md-4">
                                        <span class="form_info" id="appID" ></span>
                                    </div>
                                </div>
                            </div>

                            <div class="row clearfix add_hide">
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                        APPKEY：
                                    </div>
                                    <div class="col-md-4">
                                        <span class="form_info" id="appKey" ></span>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="row clearfix">
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                        设备：
                                    </div>
                                    <div class="col-md-4">
                                        <select class="form-control" id="device">
                                            <option value="ios">ios</option>
                                            <option value="android">android</option>
                                        </select>
                                    </div>
                                    <div class="col-md-2 text_warning text_left form_bar">
                                        * 
                                    </div>
                                </div>
                            </div>
                            
                            <div class="row clearfix" >
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                       版本号：
                                    </div>
                                    <div class="col-md-4">
                                        <input id="version" type="text" class="form-control" />
                                    </div>
                                    <div class="col-md-2 text_warning text_left form_bar">
                                          * 
                                    </div>
                                </div>
                            </div>
                            
                            <div class="row clearfix" >
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                       下载URL：
                                    </div>
                                    <div class="col-md-4">
                                        <input id="url" type="text" class="form-control" />
                                    </div>
                                </div>
                            </div>
                            
                            <div class="row clearfix" >
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                       状态：
                                    </div>
                                    <div class="col-md-4">
                                        <select class="form-control" id="status">
                                            <option value="0">未发布</option>
                                            <option value="1">已发布</option>
                                            <option value="2">停用</option>
                                        </select>
                                    </div>
                                    <div class="col-md-2 text_warning text_left form_bar">
                                          * 
                                    </div>
                                </div>
                            </div>
                            
                            <div class="row clearfix" >
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                       备注：
                                    </div>
                                    <div class="col-md-4">
                                        <textarea id="content" class="form-control" ></textarea>
                                    </div>
                                    <div class="col-md-2 text_warning text_left form_bar">
                                          * 
                                    </div>
                                </div>
                            </div>
                            
                             <input type="hidden" id="verID" />
                        </div>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" id="save" >保存</button>
                    </div>
                </div>
            </div>
        </div><!-- 任务基本信息 Modal - 结束 -->
                
        <include file="Include/script" />
        <script src="__STATICS__/js/bootstrap-editable.min.js"></script>

       <script>
            var isReload = false; // 标识弹出框关闭之后是否刷新页面
            var myDom; // 当前操作的dom对象
            var img_url="__STATICS__/images";
            
                function onSave(rsp) {
                    if(rsp.result > 0) {
                        swal("操作成功","","success");
                        window.location.reload();
                    } else {
                        swal("操作失败;"+rsp.desc,"","error");
                    }
                }
                
                /*清空弹出框内容*/
                function reset_display()
                {
                    $(".add_hide").show();
                    $("#verID").val("");
                    $("#appID").html("");
                    $("#appKey").html("");
                    $("#device").val("");
                    $("#version").val("");
                    $("#url").val("");
                    $("#status").val("");     
                    $("#content").val("");     
                    $("#myModalLabel").html("");
                    
                }
                 
                function onDel(rsp) {
                    if(rsp.result > 0) {
                        window.location.reload();
                    } else {
                        swal("操作失败",'',"error");
                    }
                }
                
            /*菜单展开及高亮*/
            $(function () {
                $('.system').addClass('open');
                $('#system4').addClass('active');

                /*基本信息的弹出框隐藏后*/
                $('#myModal').on('hidden.bs.modal', function (e) {
                     reset_display();
                });
                
                /*编辑*/
                $(".edit_look").on("click", function () {
                    var self = $(this);
                    var verID = self.closest("td").attr("data-id");
                    var appID = self.closest("td").attr("data-appid");
                    var appKey = self.closest("td").attr("data-appkey");
                    var device = self.closest("td").attr("data-device");
                    var version = self.closest("td").attr("data-version");
                    var url = self.closest("td").attr("data-url");
                    var status = self.closest("td").attr("data-status");
                    var content = self.closest("td").attr("data-content");
                    var addTime = self.closest("td").attr("data-time");
                    
                    $("#verID").val(verID);
                    $("#appID").html(appID);
                    $("#appKey").html(appKey);
                    $("#device").val(device);
                    $("#version").val(version);
                    $("#url").val(url);
                    $("#status").val(status);
                    $("#content").val(content);
                    
                    $("#myModalLabel").html("编辑(添加时间:"+addTime+")");
                    $('#myModal').modal(); // 跳出弹窗

                });
                
                /*删除弹窗*/
                $(".tar_delete").on("click", function () {
                    var self = $(this);
                    swal({   title: "您确定吗?",
                                text: "您将删除此版本！！",
                                type: "warning",
                                showCancelButton: true,
                                confirmButtonColor: "#DD6B55",
                                confirmButtonText: "是的，删除",
                                cancelButtonText: "放弃",
                                closeOnConfirm: false
                            },
                            function (isConfirm) {
                                if (isConfirm) {
                                    var ajaxData = {};
                                    ajaxData.verID = self.closest('td').attr('data-id');
                                    ajax_go_1(ajaxData ,'deleteVersion', onDel);
                                }

                            });
                });
               
                /*添加时候弹窗*/
                $("#add_look").on("click", function() {
                    $(".add_hide").hide();
                    $("#myModalLabel").html("添加版本");
                    $('#myModal').modal(); // 跳出弹窗
                });
                
                /*点击保存*/
                $("#save").on("click", function () {
                    var rt = true;
                                        
                    var device = $.trim($("#device").val());
                    var version = $.trim($("#version").val());
                    var url = $.trim($("#url").val());
                    var status = $.trim($("#status").val());
                    var verID = $("#verID").val();
                    var content = $("#content").val();
                    
                    if(device === '')
                    {   
                        rt = false;
                        $('#device').focus();
                        swal('请选择设备','','warning');
                    }else if(version === '')
                    {   
                        rt = false;
                        $('#version').focus();
                        swal('请输入版本号','','warning');
                    }
                    
                    if(rt) {
                        var ajaxData ={};
                        ajaxData.device = device;
                        ajaxData.version = version;
                        ajaxData.url = url;
                        ajaxData.status = status;
                        ajaxData.content = content;
                        if(verID > 0) {
                            ajaxData.verID = verID;
                        }
                        
                         ajax_go_1(ajaxData ,"saveVersion",onSave);
                    } else {
                        return rt;
                    }
                    
                });
                                

            });
                        
        </script>
    </body>
</html>